package com.amumu.drama.admin.modules.game.controller;

import com.amumu.drama.common.base.api.CommonPage;
import com.amumu.drama.common.base.api.CommonResult;
import com.amumu.drama.common.modules.category.dto.GameQueryDto;
import com.amumu.drama.common.modules.category.dto.GameTemplateDto;
import com.amumu.drama.common.modules.category.dto.GameTemplateQueryDto;
import com.amumu.drama.common.modules.category.service.PmsProductTemplateService;
import com.amumu.drama.common.modules.category.vo.GameTemplateInfoVo;
import com.amumu.drama.common.modules.category.vo.GameTemplateVo;
import com.amumu.drama.common.modules.category.vo.GameVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 商品分类管理Controller
 * Created by macro on 2018/4/26.
 */
@RestController
@Api(tags = "微丸子-游戏模板管理")
@RequestMapping("/gameTemplate")
public class GameTemplateController {
    @Autowired
    private PmsProductTemplateService pmsProductTemplateService;

    @ApiOperation("添加/编辑游戏模板")
    @RequestMapping(value = "/addOrUpdateGameTemplate", method = RequestMethod.POST)
    public CommonResult<String> addOrUpdateGameTemplate(@Validated @RequestBody GameTemplateDto gameTemplateDto) {
        return pmsProductTemplateService.addOrUpdateGameTemplate(gameTemplateDto);
    }

    @ApiOperation("删除游戏模板")
    @RequestMapping(value = "/deleteGameTemplate/{gameTemplateId}", method = RequestMethod.GET)
    public CommonResult<String> deleteGameTemplate(@PathVariable Long gameTemplateId) {
        return pmsProductTemplateService.deleteGameTemplate(gameTemplateId);
    }

    @ApiOperation("解除游戏绑定")
    @GetMapping(value = "/unbindGame/{gameTemplateId}")
    public CommonResult<String> unbindGame(@PathVariable Long gameTemplateId) {
        return pmsProductTemplateService.unbindGame(gameTemplateId);
    }

    @ApiOperation("游戏模板可绑定游戏列表")
    @RequestMapping(value = "/pageGameList", method = RequestMethod.POST)
    public CommonResult<CommonPage<GameVo>> pageGameList(@Validated @RequestBody GameQueryDto gameQueryDto) {
        return CommonResult.success(pmsProductTemplateService.pageGameList(gameQueryDto));
    }

    @ApiOperation("查询游戏模板列表")
    @RequestMapping(value = "/pageGameTemplateList", method = RequestMethod.POST)
    public CommonResult<IPage<GameTemplateVo>> pageGameTemplateList(@Validated @RequestBody GameTemplateQueryDto gameTemplateQueryDto) {
        return CommonResult.success(pmsProductTemplateService.pageGameTemplateList(gameTemplateQueryDto));
    }

    @ApiOperation("获取游戏模板详情")
    @RequestMapping(value = "/getGameTemplateInfo/{gameTemplateId}", method = RequestMethod.GET)
    public CommonResult<GameTemplateInfoVo> getGameTemplateInfo(@PathVariable Long gameTemplateId) {
        return pmsProductTemplateService.getGameTemplateInfo(gameTemplateId);
    }
}
